﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.Profile;
using IronOne.SalesOne.BusinessObjects;
using System.Configuration;
using Facade;
using System.Collections;
using System.Data;

namespace IronOne.SalesOne.SalesOneWeb.ContactManagement
{
    public partial class DependantDetails : SOSecurityPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    if (!string.IsNullOrEmpty(Request.UrlReferrer.ToString()))
                    {
                        ViewState["refUrl"] = Request.UrlReferrer.ToString();
                    }

                    ValidateUserCredentials(Request.Url.LocalPath);

                    if (!string.IsNullOrEmpty(Request.QueryString["nid"]))
                    {
                        int nid = Convert.ToInt32(Request.QueryString["nid"]);
                        GridViewRow depRow = (GridViewRow)Session["dependant"];
                        lblProspect.Text = "Needs Analysis No:";
                        lblProspectId.Text = nid.ToString();

                        lblDob.Text = depRow.Cells[8].Text;
                        lblDependentType.Text = depRow.Cells[6].Text;
                        lblName.Text = depRow.Cells[5].Text;
                        lblGender.Text = depRow.Cells[7].Text;
                        lblRemarks.Text = depRow.Cells[9].Text;
                        Session.Remove("dependant");
                    }
                    else
                    {
                        if (Session["prospectId"] != null && Session["dependant"] != null)
                        {
                            GridViewRow depRow = (GridViewRow)Session["dependant"];
                            lblProspectId.Text = Session["prospectId"].ToString();
                            lblDob.Text = depRow.Cells[5].Text;
                            lblDependentType.Text = depRow.Cells[7].Text;
                            lblName.Text = depRow.Cells[4].Text;
                            lblGender.Text = depRow.Cells[6].Text;
                            lblRemarks.Text = depRow.Cells[8].Text;

                            //Session.Remove("dependant");
                            //Session.Remove("prospectId");
                        }
                    }
                }
            }
            catch (Exception)
            {

            }

        }

        protected void cancelButton_Click(object sender, EventArgs e)
        {
            Response.Redirect(ViewState["refUrl"].ToString());
        }
    }
}
